package io.renren.common.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.ExchangeBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {
    @Bean("cairi_msa_exchange")
    public Exchange cairiMsaExchange(){
        return ExchangeBuilder.topicExchange("cairi_msa_exchange").durable(true).build();
    }
    @Bean("cairi_msa_queue")
    public Queue cairiMsaQueue(){
        return QueueBuilder.durable("cairi_msa").build();
    }
    @Bean
    public Binding bindCairiMsaQueueExchange(@Qualifier("cairi_msa_queue") Queue queue, @Qualifier("cairi_msa_exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("cairi_msa.#").noargs();
    }

    //生物可视化
    @Bean("biological_visualization_exchange")
    public Exchange biologicalVisualizationExchange(){
        return ExchangeBuilder.topicExchange("biological_visualization_exchange").durable(true).build();
    }
    @Bean("biological_visualization_train_queue")
    public Queue biologicalVisualizationTrainQueue(){
        return QueueBuilder.durable("biological_visualization_train").build();
    }
    @Bean
    public Binding bindBiologicalVisualizationTrainExchange(@Qualifier("biological_visualization_train_queue") Queue queue, @Qualifier("biological_visualization_exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("biological_visualization_train.#").noargs();
    }
    @Bean("biological_visualization_explan_queue")
    public Queue biologicalVisualizationExplanQueue(){
        return QueueBuilder.durable("biological_visualization_explan").build();
    }
    @Bean
    public Binding bindBiologicalVisualizationExplanExchange(@Qualifier("biological_visualization_explan_queue") Queue queue, @Qualifier("biological_visualization_exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("biological_visualization_explan.#").noargs();
    }

    //单细胞数据分析
    @Bean("single_cell_analysis_exchange")
    public Exchange singleCellAnalysisExchange(){
        return ExchangeBuilder.topicExchange("single_cell_analysis_exchange").durable(true).build();
    }
    @Bean("single_cell_analysis_train_queue")
    public Queue singleCellAnalysisTrainQueue(){
        return QueueBuilder.durable("single_cell_analysis_train").build();
    }
    @Bean
    public Binding bindSingleCellAnalysisTrainExchange(@Qualifier("single_cell_analysis_train_queue") Queue queue, @Qualifier("single_cell_analysis_exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("single_cell_analysis_train.#").noargs();
    }
    @Bean("single_cell_analysis_explan_queue")
    public Queue singleCellAnalysisExplanQueue(){
        return QueueBuilder.durable("single_cell_analysis_explan").build();
    }
    @Bean
    public Binding bindSingleCellAnalysisExplanExchange(@Qualifier("single_cell_analysis_explan_queue") Queue queue, @Qualifier("single_cell_analysis_exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("single_cell_analysis_explan.#").noargs();
    }

    // 小分子ADMET属性预测
    @Bean("admet_exchange")
    public Exchange admetExchange(){
        return ExchangeBuilder.topicExchange("admet_exchange").durable(true).build();
    }
    @Bean("admet_queue")
    public Queue admetQueue(){
        return QueueBuilder.durable("admet").build();
    }
    @Bean
    public Binding bindAdmetQueueExchange(@Qualifier("admet_queue") Queue queue, @Qualifier("admet_exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("admet.#").noargs();
    }

    // 蛋白质序列设计
    @Bean("protein_sequence_design_exchange")
    public Exchange proteinSequenceDesignExchange(){
        return ExchangeBuilder.topicExchange("protein_sequence_design_exchange").durable(true).build();
    }
    @Bean("protein_sequence_design_queue")
    public Queue proteinSequenceDesignQueue(){
        return QueueBuilder.durable("protein_sequence_design").build();
    }
    @Bean
    public Binding bindProteinSequenceDesignExchange(@Qualifier("protein_sequence_design_queue") Queue queue, @Qualifier("protein_sequence_design_exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("protein_sequence_design.#").noargs();
    }

    // 基因编辑
    @Bean("gene_editing_exchange")
    public Exchange geneEditingExchange(){
        return ExchangeBuilder.topicExchange("gene_editing_exchange").durable(true).build();
    }
    @Bean("gene_editing_queue")
    public Queue geneEditingQueue(){
        return QueueBuilder.durable("gene_editing").build();
    }
    @Bean
    public Binding bindGeneEditingQueueExchange(@Qualifier("gene_editing_queue") Queue queue, @Qualifier("gene_editing_exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("gene_editing.#").noargs();
    }

}
